﻿using System;
using CamlexNET;
using LifeInSharePoint.Common;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace LifeInSharePoint.Blog.Layouts.LifeInSharePoint.Blog.admin
{
    public partial class admanagement : LayoutsPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            PopulateArticleSizeDropdownBox();
        }

        protected void PopulateArticleSizeDropdownBox()
        {
            //Get the SP Web
            SPWeb web = SPContext.Current.Site.RootWeb;

            //Get the List Instance
            SPList newslist = web.Lists["Advertisement Size"];

            //Get a new SPQuery Instance
            SPQuery workQuery = new SPQuery();
            workQuery.Query = "<OrderBy><FieldRef Name='Modified' Ascending='False'/></OrderBy>";

            SPListItemCollection _workItemCollection = newslist.GetItems(workQuery);

            if (_workItemCollection != null && _workItemCollection.Count > 0)
            {
                foreach (SPListItem _workItem in _workItemCollection)
                {
                    NewAdvertSize.Items.Add(SPListHelper.GetColumnStringValue(_workItem,"Title"));
                }
            }
        }
    }
}
